home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / taropyon / hewin / ccisrc / center04.cci < prev    next >
Text File  |  1993-11-30  |  7KB  |  275 lines

  1. /*************************************************************************
  2. *    "center04.cci" : CENTER04用センター処理
  3. *-------------------------------------------------------------------------
  4. *    Turbo-BBS 系
  5. *************************************************************************/
  6.  
  7. #ifdef    CENTERKEY
  8. #undef    CENTERKEY
  9. #endif
  10. #ifdef    RECKEY
  11. #undef    RECKEY
  12. #endif
  13.  
  14. #define    CENTERKEY    "CENTER04"
  15. #define    RECKEY        _center04_recKey
  16.  
  17. char    *_center04_recKey;
  18.  
  19. int        _CENTER04_init()
  20. {
  21.     char    *center;
  22.  
  23.     if ( (center = NTM_centerAlloc( CENTERKEY )) != NULL )
  24.     {
  25.         NtmCenterSetName   ( center, "Sample center (type-04:Turbo-BBS)");
  26.         NtmCenterSetFuncKey( center, "CENTER04");
  27.         NtmCenterSetRecKey ( center, "CENTER04");
  28.         NtmCenterSetRsPara ( center, -1, -1, -1 );
  29.         NtmCenterSetRsBreak( center, 50 );
  30.         NtmCenterSetCrWait ( center, 100 );
  31.         NtmCenterSetTel    ( center, "XX-XXXX-XXXX" );
  32.         NtmCenterSetModem1 ( center, "ATZ" );
  33.     }
  34.     return (NORMAL);
  35. }
  36.  
  37. /*************************************************************************
  38. *    ナビゲーション用初期化
  39. *************************************************************************/
  40.  
  41. int        _CENTER04_naviInit( char *ntm, char *center )
  42. {
  43.     NtmSetNaviServiceMode( ntm, 0 );    /* ナビゲーションシステムなし    */
  44.     return (NORMAL);
  45. }
  46.  
  47.  
  48. /*************************************************************************
  49. *    パラメータの指定
  50. *************************************************************************/
  51.  
  52. int        _CENTER04_para( char *ntm, char *center )
  53. {
  54.     char    *keyWord;
  55.     char    *id, *pw;
  56.  
  57.     keyWord = NtmCenterGetKeyWord(center);
  58.     if ( NTM_centerConfig( keyWord ) == NORMAL )
  59.     {
  60.         id  = NtmCenterGetID      ( center );
  61.         pw  = NtmCenterGetPassword( center );
  62.         if ( id[0] == 0 || pw[0] == 0 )
  63.             return (ERR);
  64.         return (NORMAL);
  65.     } else
  66.         return (ERR);
  67. }
  68.  
  69.  
  70. /*************************************************************************
  71. *    処理の中断
  72. *************************************************************************/
  73.  
  74. int        _CENTER04_abort( char *ntm, char *center )
  75. {
  76.     AplRecWrite("%s:Abort", RECKEY);
  77.     NTM_offline( ntm, DTR_OFF_TIME );
  78.     return (NORMAL);
  79. }
  80.  
  81. /*************************************************************************
  82. *    [AUTO]メニュー処理
  83. *************************************************************************/
  84.  
  85. int        _CENTER04_autoMenu( char *ntm, char *center, int x, int y)
  86. {
  87.     int        ret;
  88.     char    *obj;
  89.     char    *mnu;
  90.     char    title[128], tmp[128], tmBuf[32];
  91.     long    loginTime;
  92.  
  93.     if ( ntm == NULL || center == NULL )
  94.         return (0);
  95.     loginTime = NtmCenterGetTime(center, NTM_TIME_LOGIN );
  96.     if ( loginTime )
  97.     {    sprintf( tmp, "Login time %s ", GetAsciiTime(tmBuf,loginTime) );
  98.     } else
  99.     {    strcpy( tmp, "Login time XXXX/XX/XX XX:XX:XX");
  100.     }
  101.     obj = MNU_alloc(3);
  102.     MNU_setObj(obj, 0, MNU_MSG,  0 , tmp               , NULL, 0, NULL, NULL );
  103.     MNU_setObj(obj, 1, MNU_NOR, 'O', "OFF 終了"        , NULL, 1, NULL, NULL );
  104.     MNU_setObj(obj, 2, MNU_NOR, 'B', "OFF 強制回線切断", NULL, 2, NULL, NULL );
  105.  
  106.     sprintf( title, "MENU : %s", NtmCenterGetName(center));
  107.     mnu = MNU_open( x, y, MNUATT_EXIT, obj, title );
  108.     ret = MNU_start ( mnu );
  109.     MNU_close(mnu);
  110.     MNU_free(obj);
  111.     switch ( ret )
  112.     {
  113.         case 1:
  114.             return    NTM_callLogout( ntm );
  115.         case 2:
  116.             NTM_wait(3);
  117.             AplRecWrite("%s:Abort disconnect", RECKEY);
  118.             return    NTM_offline(ntm, DTR_OFF_TIME);
  119.     }
  120.     return (NORMAL);
  121. }
  122.  
  123. /*************************************************************************
  124. *    ログイン処理
  125. *************************************************************************/
  126.  
  127. int        _CENTER04_login( char *ntm, char *center )
  128. {
  129.     int        i, ret, retry;
  130.     char    *name, *tel, *id, *pw, *para;
  131.     int        argc;
  132.     char    *s, **argv;
  133.     long    tm;
  134.     char    *cns;
  135.     char    *mos;
  136.  
  137.     mos = NULL;
  138.     cns = NtmGetCnsPtr(ntm);
  139. #ifdef    _TAROPYON_SYSTEM
  140.     /* ログ保存行数を増やす    */
  141.     if ( CnsGet_maxLinBuf(cns) < 99999 )
  142.         CnsSet_maxLinBuf(cns,99999);
  143. #endif
  144.     _center04_recKey = NtmCenterGetRecKey(center);
  145.  
  146.     name = NtmCenterGetName    ( center );
  147.     tel  = NtmCenterGetTel     ( center );
  148.     id   = NtmCenterGetID      ( center );
  149.     pw   = NtmCenterGetPassword( center );
  150.     if ( tel[0] == 0 || id[0] == 0 || pw[0] == 0 )
  151.     {
  152.         _ntm_errmsg_no_setup_id_and_pw();
  153.         if ( _CENTER04_para( ntm, center ) )
  154.             return (ERR);
  155.         id  = NtmCenterGetID      ( center );
  156.         pw  = NtmCenterGetPassword( center );
  157.         tel = NtmCenterGetTel     ( center );
  158.     }
  159.  
  160.     _ntm_dspmsg_dial_start( name, tel, cns );
  161.  
  162.     AplRecWrite("%s:Dial start tel.%s", RECKEY, tel );
  163.     if ( ntm_dialStart( ntm, tel ) != NORMAL )
  164.     {
  165. ABORT:    _CENTER04_abort( ntm, center );
  166.         if ( mos )    MOS_pop(mos);
  167.         return (ERR);
  168.     }
  169.  
  170.     mos = MOS_push();
  171.     MOS_curType(MOSCUR_TIME);
  172.     MOS_CON();
  173.     AplRecWrite("%s:Connect", RECKEY );
  174.  
  175.     ret = NTM_waitInstr( ntm, 30, "User ID  = ", NULL );
  176.     if ( ret == NTM_WAIT_CANCEL )
  177.         goto ABORT;
  178.     NTM_wait(1);
  179.     NTM_rsPuts( ntm, id );    NTM_rsPuts(ntm,"\r");
  180.  
  181.     ret = NTM_waitStr( ntm, 30, "Password = ", NULL);
  182.     if ( ret == NTM_WAIT_CANCEL )
  183.         goto ABORT;
  184.     NTM_wait(1);
  185.     NTM_rsPuts( ntm, pw );    NTM_rsPuts(ntm,"\r");
  186.  
  187.     /* ログイン時間    */
  188.     time(&tm);
  189.     NtmCenterSetTime( center, NTM_TIME_LOGIN, tm );
  190.     AplRecWrite("%s:Login successful", RECKEY );
  191.     MOS_pop(mos);
  192.  
  193.     return (NORMAL);
  194. }
  195.  
  196.  
  197. /*************************************************************************
  198. *    ログアウト処理
  199. *************************************************************************/
  200.  
  201. int        _CENTER04_logout( char *ntm, char *center )
  202. {
  203.     int        ret;
  204.     long    tm;
  205.  
  206.     time(&tm);
  207.     NtmCenterSetTime( center, NTM_TIME_LOGOUT, tm );
  208.     AplRecWrite("%s:Logout", RECKEY);
  209.     NTM_wait(1);
  210.     NTM_rsPuts( ntm, "O\r");
  211.  
  212.     NTM_waitInstr( ntm, 30, "(Y/[N]) >", NULL );
  213.     if ( ret != NTM_WAIT_CANCEL )
  214.     {
  215.         NTM_rsPuts( ntm, "Y\r");
  216.     }
  217.  
  218.     NTM_waitInstr( ntm, 30, "NO CARRIER", NULL );
  219.     NTM_offline(ntm, DTR_OFF_TIME);
  220.     AplRecWrite("%s:Disconnect", RECKEY);
  221.     return (NORMAL);
  222. }
  223.  
  224. /*************************************************************************
  225. *    受信行のチェック
  226. *************************************************************************/
  227.  
  228. int        _CENTER04_lineCheck( char *ntm, char *buf )
  229. {
  230.     return (NORMAL);
  231. }
  232.  
  233. /*************************************************************************
  234. *    入力文字列の送信
  235. *************************************************************************/
  236.  
  237. int        _CENTER04_inputCheck( char *ntm, char *s )
  238. {
  239.     NTM_rsPuts( ntm, s    );
  240.     NTM_rsPuts( ntm, "\r" );
  241.     return (NORMAL);
  242. }
  243.  
  244. /*************************************************************************
  245. *    フィルタ設定メニュー
  246. *************************************************************************/
  247.  
  248. int        _CENTER04_filterMenu( char *ntm, int x, int y )
  249. {
  250.     return    NtmUsr_filterMenu( ntm, x, y );
  251. }
  252.  
  253. int        CCI_dspCenter04Stt()
  254. {
  255.     char    *center;
  256.     char    *name;
  257.     long    loginTime, logoutTime;
  258.     char    t1[32], t2[32];
  259.  
  260.     if ( (center = NTM_getCenter(CENTERKEY)) == NULL )
  261.         return (ERR);
  262.     name = NtmCenterGetName(center);
  263.     loginTime  = NtmCenterGetTime( center, NTM_TIME_LOGIN );
  264.     logoutTime = NtmCenterGetTime( center, NTM_TIME_LOGOUT );
  265.     DLG_tmpMsgBox( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN, 
  266.         C_MBLACK, C_DLGBASE, COLMIX(C_INFO,C_GRAY),
  267.         "  センター名 : %s\n  Login time       %s  \n  Last logout time %s  ",
  268.         name, GetAsciiTime(t1, loginTime), GetAsciiTime(t2,logoutTime) );
  269.     return (NORMAL);
  270. }
  271.  
  272.  
  273. #undef    CENTERKEY
  274. #undef    RECKEY
  275.